const fs = require('fs');
const path = require('path');

// 创建必要的目录
const dirs = [
  'logs',
  'dist',
  'src/utils',
  'src/services',
  'src/controllers',
  'src/middleware',
  'src/routes'
];

console.log('🚀 正在初始化项目目录结构...');

dirs.forEach(dir => {
  const dirPath = path.join(__dirname, '..', dir);
  if (!fs.existsSync(dirPath)) {
    fs.mkdirSync(dirPath, { recursive: true });
    console.log(`✅ 创建目录: ${dir}`);
  } else {
    console.log(`ℹ️ 目录已存在: ${dir}`);
  }
});

// 创建.gitkeep文件以保持空目录
['logs/.gitkeep'].forEach(file => {
  const filePath = path.join(__dirname, '..', file);
  if (!fs.existsSync(filePath)) {
    fs.writeFileSync(filePath, '');
    console.log(`✅ 创建文件: ${file}`);
  }
});

console.log('✨ 项目初始化完成!');
